﻿#ifndef TRANSFERBASE_H
#define TRANSFERBASE_H
#include <QString>
#include <QTcpSocket>
#include "TransferProxy.h"

#define INFOFLAG "@:"

class TransferProxy;
class TransferBase {
public:
    //一定需要TcpSocket套接字
    TransferBase(TransferProxy* proxy);
    //获取一个前缀，每个聊天的类都有一个前缀的，根据前缀去调用子类
    //声明为纯虚函数，子类必须实现
    virtual QString transferPrefix() = 0;
    //发送消息
    virtual void    send(const QVariant &var, const QVariant &extra) = 0;
    //收到消息
    virtual void    received(const QVariant &var) = 0;
    void            setRunningFlag(bool flag){mRunningFlag = flag;}
    bool            isRunning(){return mRunningFlag;}

protected:
    TransferProxy*  mTransproxy = nullptr;
    //接受文件和图片的可能一次接受不完,就要把该标志位设置为true，下一层还要读取
    bool            mRunningFlag = false;
};

#endif // TRANSFERBASE_H
